import Router from 'vue-router'

// import routes from './routes'
// import Todo from '../views/todo/todo.vue'
// import Login from '../views/login/login.vue'
const routes = [
  {
    path: '/',
    redirect: '/app'
  },
  {
    path: '/app',
    component: () => import('../views/todo/todo.vue'),
    props: true // :id的值会直接传入Todo组件的props
    // name: 'app',
    // meta: {
    //   title: 'dodo'
    // },
    // children: [
    //   {}
    // ] // 嵌套路由
  },
  {
    path: '/login',
    component: () => import('../views/login/login.vue')
  }
]

export default () => {
  return new Router({
    routes,
    mode: 'history',
    scrollBehavior (to, from, savedPosition) {
      if (savedPosition) {
        return savedPosition
      } else {
        return {
          x: 0,
          y: 0
        }
      }
    },
    fallback: true // 浏览器不支持history模式的时候，vue自动转为hash模式
  })
}
